package com.esri.core.internal.tasks.d;

import com.esri.core.geometry.Geometry;
import com.esri.core.geometry.SpatialReference;
import com.esri.core.map.Graphic;
import com.esri.core.tasks.na.AttributeParameterValue;
import com.esri.core.tasks.na.DirectionsLengthUnit;
import com.esri.core.tasks.na.DirectionsOutputType;
import com.esri.core.tasks.na.NAFeatures;
import com.esri.core.tasks.na.NAFeaturesAsFeature;
import com.esri.core.tasks.na.NAFeaturesAsLayer;
import com.esri.core.tasks.na.NAOutputLine;
import com.esri.core.tasks.na.UTurnRestriction;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.JsonToken;

/* loaded from: classes.dex */
public class e extends c {
    private static final long serialVersionUID = 1;
    private NAFeatures r = null;
    private boolean s = true;
    private boolean t = true;
    private boolean u = false;
    private Boolean v = null;
    private Boolean w = null;
    private Boolean x = null;
    private Boolean y = null;
    private Boolean z = null;
    private Long A = null;
    private String B = null;
    private DirectionsOutputType C = DirectionsOutputType.STANDARD;
    private String D = null;
    private DirectionsLengthUnit E = null;
    private String F = null;

    public NAFeatures a() {
        return this.r;
    }

    public void a(NAFeatures nAFeatures) {
        this.r = nAFeatures;
    }

    public boolean b() {
        return this.s;
    }

    public void a(boolean z) {
        this.s = z;
    }

    public boolean c() {
        return this.t;
    }

    public void b(boolean z) {
        this.t = z;
    }

    public boolean d() {
        return this.u;
    }

    public void c(boolean z) {
        this.u = z;
    }

    public Boolean e() {
        return this.v;
    }

    public void b(Boolean bool) {
        this.v = bool;
    }

    public Boolean f() {
        return this.w;
    }

    public void c(Boolean bool) {
        this.w = bool;
    }

    public Boolean g() {
        return this.x;
    }

    public void d(Boolean bool) {
        this.x = bool;
    }

    public Boolean h() {
        return this.y;
    }

    public void e(Boolean bool) {
        this.y = bool;
    }

    public Boolean i() {
        return this.z;
    }

    public void f(Boolean bool) {
        this.z = bool;
    }

    public Long j() {
        return this.A;
    }

    public void a(Long l) {
        this.A = l;
    }

    public String k() {
        return this.B;
    }

    public void a(String str) {
        this.B = str;
    }

    public DirectionsOutputType l() {
        return this.C;
    }

    public void a(DirectionsOutputType directionsOutputType) {
        this.C = directionsOutputType;
    }

    public String m() {
        return this.D;
    }

    public void b(String str) {
        this.D = str;
    }

    public DirectionsLengthUnit n() {
        return this.E;
    }

    public void a(DirectionsLengthUnit directionsLengthUnit) {
        this.E = directionsLengthUnit;
    }

    public String o() {
        return this.F;
    }

    public void c(String str) {
        this.F = str;
    }

    @Override // com.esri.core.internal.tasks.f
    public Map<String, String> generateRequestParams() throws Exception {
        LinkedHashMap linkedHashMap = (LinkedHashMap) H();
        if (this.r == null || !p()) {
            throw new IllegalArgumentException("Invalid stops. Need at least two stops in order to perform route solving");
        }
        linkedHashMap.put("stops", this.r.toJson());
        linkedHashMap.put("returnDirections", Boolean.toString(this.s));
        linkedHashMap.put("returnRoutes", Boolean.toString(this.t));
        linkedHashMap.put("returnStops", Boolean.toString(this.u));
        Boolean bool = this.v;
        if (bool != null) {
            linkedHashMap.put("ignoreInvalidLocations", bool.toString());
        }
        if (this.i != null) {
            linkedHashMap.put("outputLines", this.i.toString());
        }
        Boolean bool2 = this.w;
        if (bool2 != null) {
            linkedHashMap.put("findBestSequence", bool2.toString());
        }
        Boolean bool3 = this.x;
        if (bool3 != null) {
            linkedHashMap.put("preserveFirstStop", bool3.toString());
        }
        Boolean bool4 = this.y;
        if (bool4 != null) {
            linkedHashMap.put("preserveLastStop", bool4.toString());
        }
        Boolean bool5 = this.z;
        if (bool5 != null) {
            linkedHashMap.put("useTimeWindows", bool5.toString());
        }
        Long l = this.A;
        if (l != null) {
            linkedHashMap.put("startTime", l.toString());
        }
        String str = this.B;
        if (str != null && str.length() > 0) {
            linkedHashMap.put("directionsLanguage", this.B);
        }
        linkedHashMap.put("directionsOutputType", this.C.toString());
        String str2 = this.D;
        if (str2 != null && str2.length() > 0) {
            linkedHashMap.put("directionsStyleName", this.D);
        }
        DirectionsLengthUnit directionsLengthUnit = this.E;
        if (directionsLengthUnit != null) {
            linkedHashMap.put("directionsLengthUnits", directionsLengthUnit.toString());
        }
        String str3 = this.F;
        if (str3 != null && str3.length() > 0) {
            linkedHashMap.put("directionsTimeAttributeName", this.F);
        }
        return linkedHashMap;
    }

    private boolean p() {
        String layerName;
        if (!this.r.getClass().toString().equals("class com.esri.core.tasks.na.NAFeaturesAsFeature")) {
            return this.r.getClass().toString().equals("class com.esri.core.tasks.na.NAFeaturesAsLayer") && (layerName = ((NAFeaturesAsLayer) this.r).getLayerName()) != null && layerName.length() >= 1;
        }
        String url = ((NAFeaturesAsFeature) this.r).getURL();
        List<Graphic> features = ((NAFeaturesAsFeature) this.r).getFeatures();
        if ((url == null || url.length() == 0) && (features == null || features.size() < 2)) {
            return false;
        }
        if (features != null && !features.isEmpty()) {
            for (Graphic graphic : features) {
                if (graphic.getGeometry().getType() != Geometry.Type.POINT) {
                    return false;
                }
            }
        }
        return true;
    }

    public static e a(JsonParser jsonParser) throws Exception {
        if (com.esri.core.internal.util.d.c(jsonParser)) {
            e eVar = new e();
            while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
                String currentName = jsonParser.getCurrentName();
                jsonParser.nextToken();
                if ("impedance".equals(currentName)) {
                    eVar.k = jsonParser.getCurrentToken() == JsonToken.VALUE_NULL ? null : jsonParser.getText();
                } else if ("restrictions".equals(currentName)) {
                    eVar.l = jsonParser.getCurrentToken() == JsonToken.VALUE_NULL ? null : b(jsonParser);
                } else if ("ignoreInvalidLocations".equals(currentName)) {
                    eVar.v = jsonParser.getCurrentToken() == JsonToken.VALUE_NULL ? null : Boolean.valueOf(jsonParser.getBooleanValue());
                } else if ("restrictUTurns".equals(currentName)) {
                    eVar.m = jsonParser.getCurrentToken() == JsonToken.VALUE_NULL ? null : UTurnRestriction.get(jsonParser.getText());
                } else if ("accumulateAttributeNames".equals(currentName)) {
                    eVar.j = jsonParser.getCurrentToken() == JsonToken.VALUE_NULL ? null : b(jsonParser);
                } else if ("attributeParameterValues".equals(currentName)) {
                    if (jsonParser.getCurrentToken() == JsonToken.VALUE_NULL) {
                        eVar.d = null;
                    } else {
                        ArrayList arrayList = new ArrayList();
                        if (jsonParser.getCurrentToken() == JsonToken.START_ARRAY) {
                            while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
                                arrayList.add(AttributeParameterValue.fromJson(jsonParser));
                            }
                        }
                        eVar.d = arrayList.isEmpty() ? null : (AttributeParameterValue[]) arrayList.toArray(new AttributeParameterValue[arrayList.size()]);
                    }
                } else if ("outputSpatialReference".equals(currentName)) {
                    eVar.h = jsonParser.getCurrentToken() == JsonToken.VALUE_NULL ? null : SpatialReference.fromJson(jsonParser);
                } else if ("useHierarchy".equals(currentName)) {
                    eVar.n = jsonParser.getCurrentToken() == JsonToken.VALUE_NULL ? null : Boolean.valueOf(jsonParser.getBooleanValue());
                } else if ("findBestSequence".equals(currentName)) {
                    eVar.w = jsonParser.getCurrentToken() == JsonToken.VALUE_NULL ? null : Boolean.valueOf(jsonParser.getBooleanValue());
                } else if ("startTime".equals(currentName) && jsonParser.getCurrentToken() == JsonToken.VALUE_NUMBER_INT) {
                    eVar.A = jsonParser.getCurrentToken() == JsonToken.VALUE_NULL ? null : Long.valueOf(jsonParser.getLongValue());
                } else if ("useTimeWindows".equals(currentName)) {
                    eVar.z = jsonParser.getCurrentToken() == JsonToken.VALUE_NULL ? null : Boolean.valueOf(jsonParser.getBooleanValue());
                } else if ("preserveFirstStop".equals(currentName)) {
                    eVar.x = jsonParser.getCurrentToken() == JsonToken.VALUE_NULL ? null : Boolean.valueOf(jsonParser.getBooleanValue());
                } else if ("preserveLastStop".equals(currentName)) {
                    eVar.y = jsonParser.getCurrentToken() == JsonToken.VALUE_NULL ? null : Boolean.valueOf(jsonParser.getBooleanValue());
                } else if ("outputLineType".equals(currentName)) {
                    eVar.i = jsonParser.getCurrentToken() == JsonToken.VALUE_NULL ? null : NAOutputLine.get(jsonParser.getText());
                } else if ("directionsLanguage".equals(currentName)) {
                    eVar.B = jsonParser.getCurrentToken() == JsonToken.VALUE_NULL ? null : jsonParser.getText();
                } else if ("directionsLengthUnits".equals(currentName)) {
                    eVar.E = jsonParser.getCurrentToken() == JsonToken.VALUE_NULL ? null : DirectionsLengthUnit.get(jsonParser.getText());
                } else if ("directionsTimeAttribute".equals(currentName)) {
                    eVar.F = jsonParser.getCurrentToken() == JsonToken.VALUE_NULL ? null : jsonParser.getText();
                } else {
                    jsonParser.skipChildren();
                }
            }
            return eVar;
        }
        return null;
    }

    public int hashCode() {
        int hashCode = (((((Arrays.hashCode(this.j) + 31) * 31) + (this.d == null ? 0 : this.d.hashCode())) * 31) + (this.a == null ? 0 : this.a.hashCode())) * 31;
        String str = this.B;
        int hashCode2 = (hashCode + (str == null ? 0 : str.hashCode())) * 31;
        DirectionsLengthUnit directionsLengthUnit = this.E;
        int hashCode3 = (hashCode2 + (directionsLengthUnit == null ? 0 : directionsLengthUnit.hashCode())) * 31;
        DirectionsOutputType directionsOutputType = this.C;
        int hashCode4 = (hashCode3 + (directionsOutputType == null ? 0 : directionsOutputType.hashCode())) * 31;
        String str2 = this.D;
        int hashCode5 = (hashCode4 + (str2 == null ? 0 : str2.hashCode())) * 31;
        String str3 = this.F;
        int hashCode6 = (hashCode5 + (str3 == null ? 0 : str3.hashCode())) * 31;
        Boolean bool = this.w;
        int hashCode7 = (hashCode6 + (bool == null ? 0 : bool.hashCode())) * 31;
        Boolean bool2 = this.v;
        int hashCode8 = (((((((((((((((hashCode7 + (bool2 == null ? 0 : bool2.hashCode())) * 31) + (this.k == null ? 0 : this.k.hashCode())) * 31) + (this.h == null ? 0 : this.h.hashCode())) * 31) + (this.o == null ? 0 : this.o.hashCode())) * 31) + (this.p == null ? 0 : this.p.hashCode())) * 31) + (this.i == null ? 0 : this.i.hashCode())) * 31) + (this.c == null ? 0 : this.c.hashCode())) * 31) + (this.b == null ? 0 : this.b.hashCode())) * 31;
        Boolean bool3 = this.x;
        int hashCode9 = (hashCode8 + (bool3 == null ? 0 : bool3.hashCode())) * 31;
        Boolean bool4 = this.y;
        int hashCode10 = (((((((((((((((((((hashCode9 + (bool4 == null ? 0 : bool4.hashCode())) * 31) + (this.m == null ? 0 : this.m.hashCode())) * 31) + Arrays.hashCode(this.l)) * 31) + (this.e ? 1231 : 1237)) * 31) + (this.s ? 1231 : 1237)) * 31) + (this.g ? 1231 : 1237)) * 31) + (this.f ? 1231 : 1237)) * 31) + (this.t ? 1231 : 1237)) * 31) + (this.u ? 1231 : 1237)) * 31) + (this.q ? 1231 : 1237)) * 31;
        Long l = this.A;
        int hashCode11 = (hashCode10 + (l == null ? 0 : l.hashCode())) * 31;
        NAFeatures nAFeatures = this.r;
        int hashCode12 = (((hashCode11 + (nAFeatures == null ? 0 : nAFeatures.hashCode())) * 31) + (this.n == null ? 0 : this.n.hashCode())) * 31;
        Boolean bool5 = this.z;
        return hashCode12 + (bool5 != null ? bool5.hashCode() : 0);
    }

    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj != null && getClass() == obj.getClass()) {
            e eVar = (e) obj;
            if (Arrays.equals(this.j, eVar.j)) {
                if (this.d == null) {
                    if (eVar.d != null) {
                        return false;
                    }
                } else if (!this.d.equals(eVar.d)) {
                    return false;
                }
                if (this.a == null) {
                    if (eVar.a != null) {
                        return false;
                    }
                } else if (!this.a.equals(eVar.a)) {
                    return false;
                }
                String str = this.B;
                if (str == null) {
                    if (eVar.B != null) {
                        return false;
                    }
                } else if (!str.equals(eVar.B)) {
                    return false;
                }
                if (this.E == eVar.E && this.C == eVar.C) {
                    String str2 = this.D;
                    if (str2 == null) {
                        if (eVar.D != null) {
                            return false;
                        }
                    } else if (!str2.equals(eVar.D)) {
                        return false;
                    }
                    String str3 = this.F;
                    if (str3 == null) {
                        if (eVar.F != null) {
                            return false;
                        }
                    } else if (!str3.equals(eVar.F)) {
                        return false;
                    }
                    Boolean bool = this.w;
                    if (bool == null) {
                        if (eVar.w != null) {
                            return false;
                        }
                    } else if (!bool.equals(eVar.w)) {
                        return false;
                    }
                    Boolean bool2 = this.v;
                    if (bool2 == null) {
                        if (eVar.v != null) {
                            return false;
                        }
                    } else if (!bool2.equals(eVar.v)) {
                        return false;
                    }
                    if (this.k == null) {
                        if (eVar.k != null) {
                            return false;
                        }
                    } else if (!this.k.equals(eVar.k)) {
                        return false;
                    }
                    if (this.h == null) {
                        if (eVar.h != null) {
                            return false;
                        }
                    } else if (!this.h.equals(eVar.h)) {
                        return false;
                    }
                    if (this.o == null) {
                        if (eVar.o != null) {
                            return false;
                        }
                    } else if (!this.o.equals(eVar.o)) {
                        return false;
                    }
                    if (this.p == eVar.p && this.i == eVar.i) {
                        if (this.c == null) {
                            if (eVar.c != null) {
                                return false;
                            }
                        } else if (!this.c.equals(eVar.c)) {
                            return false;
                        }
                        if (this.b == null) {
                            if (eVar.b != null) {
                                return false;
                            }
                        } else if (!this.b.equals(eVar.b)) {
                            return false;
                        }
                        Boolean bool3 = this.x;
                        if (bool3 == null) {
                            if (eVar.x != null) {
                                return false;
                            }
                        } else if (!bool3.equals(eVar.x)) {
                            return false;
                        }
                        Boolean bool4 = this.y;
                        if (bool4 == null) {
                            if (eVar.y != null) {
                                return false;
                            }
                        } else if (!bool4.equals(eVar.y)) {
                            return false;
                        }
                        if (this.m == eVar.m && Arrays.equals(this.l, eVar.l) && this.e == eVar.e && this.s == eVar.s && this.g == eVar.g && this.f == eVar.f && this.t == eVar.t && this.u == eVar.u && this.q == eVar.q) {
                            Long l = this.A;
                            if (l == null) {
                                if (eVar.A != null) {
                                    return false;
                                }
                            } else if (!l.equals(eVar.A)) {
                                return false;
                            }
                            NAFeatures nAFeatures = this.r;
                            if (nAFeatures == null) {
                                if (eVar.r != null) {
                                    return false;
                                }
                            } else if (!nAFeatures.equals(eVar.r)) {
                                return false;
                            }
                            if (this.n == null) {
                                if (eVar.n != null) {
                                    return false;
                                }
                            } else if (!this.n.equals(eVar.n)) {
                                return false;
                            }
                            Boolean bool5 = this.z;
                            if (bool5 == null) {
                                if (eVar.z != null) {
                                    return false;
                                }
                            } else if (!bool5.equals(eVar.z)) {
                                return false;
                            }
                            return true;
                        }
                        return false;
                    }
                    return false;
                }
                return false;
            }
            return false;
        }
        return false;
    }
}
